<?php
/**
 * Created by PhpStorm.
 * User: prg
 * Date: 2017/3/24
 * Time: 16:14
 */

require_once 'db.php';
require_once 'response.php';

header('content-type:text/html;charset:utf-8');
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:GET');
header('Access-Control-Allow-Headers: x-requested-with,content-type');

try{
    $connect = Db::getInstance()->connect();
} catch(Exception $e) {
    return Response::show(403,'数据库连接错误',$e->getMessage());
}

$sql = "SELECT team_id,team_name,team_content,team_img FROM team WHERE team_show=0 limit 0,4";
//echo $sql;
$data = array();

$res = $connect->query($sql);

if($res && $res->num_rows>0) {
    while($team = $res->fetch_assoc()) {
        $data[] = $team;
    }
//    var_dump($data);
    return Response::show(200,'首页团队信息获取成功',$data);
} else {
    return Response::show(404,'没有获取到首页团队信息');
}